/* Copyright (c) 2011 Team A CS2340. All rights reserved.*/

package edu.gatech.teama.doctorsoffice.client.presenter;

import org.joda.time.LocalDate;

import edu.gatech.teama.doctorsoffice.model.Address;
import edu.gatech.teama.doctorsoffice.model.Doctor;
import edu.gatech.teama.doctorsoffice.model.Gender;
import edu.gatech.teama.doctorsoffice.model.Nurse;
import edu.gatech.teama.doctorsoffice.model.Patient;
import edu.gatech.teama.doctorsoffice.model.SystemAdmin;
import edu.gatech.teama.doctorsoffice.model.User;

/**
 * AddUserPresenter.java that adds a User with 
 * special considerations for if the type is Patient
 * @author Team A   
 * @version unknown
 */
public class AddUserPresenter { // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString

	/**
	 * Adds a User with certain characteristics defined.  
	 * @param type
	 * @param username
	 * @param password
	 * @param firstName
	 * @param lastName
	 * @param gender
	 * @param phone
	 * @param email 
	 * @param address 
	 * @param city
	 * @param zip
	 * @param state
	 */
	public void addUser(String type, String username, String password, String firstName, // $codepro.audit.disable largeNumberOfParameters
			String lastName, String gender, String phone, String email, String address,
			String city, String zip, String state) {
		
		final ServerConnection sc = ServerConnection.getInstance();
		User user;

		if (type.equals("Patient")) {
			final Gender g = gender.equals("Male") ? Gender.MALE : Gender.FEMALE; // $codepro.audit.disable questionableName
			user = new Patient(username, firstName, lastName, phone,
					new Address(address, zip, city, state),
					email, g, new LocalDate(), "", "");
			sc.addUser(user, password);
		} else if (type.equals("Doctor")) {
			user = new Doctor(username, firstName, lastName, phone,
					new Address(address, zip, city, state),
					email);
			sc.addUser(user, password);
		} else if (type.equals("Nurse")) {
			user = new Nurse(username, firstName, lastName, phone,
					new Address(address, zip, city, state),
					email);
			sc.addUser(user, password);
		} else if (type.equals("SystemAdmin")) {
			user = new SystemAdmin(username, firstName, lastName, phone,
					new Address(address, zip, city, state),
					email);
			sc.addUser(user, password);
		}
	}
}
